<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <script>
    const str = '234'
    const array = ['', '1', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrx', 'tuv', 'xyz']
    const args = str.split('')
    const code = args.map(item => array[item])
    const toogle = (args) => {
      let result = []
      for (let i = 0, il = args[0]; i < il.length; i++) {
        for (let j = 0, jl = args[1]; j < jl.length; j++) {
          result.push(`${il[i]}${jl[j]}`)
        } 
      }
      args.splice(0, 2, result)
      if(args.length > 1) {
        toogle(args)
      } else {
        return result
      }
      return args[0]
    }
    
    console.log(toogle(code));
    
  </script>
</body>
</html>